------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\ariottigolder.log
  log type:  text
 opened on:  30 Mar 2017, 14:06:15

. set more off

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      ariotti_golder_data.do                          *;
. *       Date:           August 28, 2016                                 *;
. *       Author:         Molly Ariotti and Sona Golder                   *;
. *       Purpose:        Create and label some variables.                *;
. *           Input File:     Africa_govt-party_obs.dta                       *;
. *       Output File:    ariottigolder.log                               *;
. *       Data Output:    Africa.dta                                      *;
.              *       Previous file:  Africa_govt-party_obs.xls --> Stata .dta        *;
. *       Machine:        laptop                                                          *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Open and summarize dataset. Generate some variables.            *;
. *     ****************************************************************  *;
. use "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa_govt-party_obs.dta";

. sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 countryname |          0
 countrycode |         84    5.559524    2.552349          1          9
 cabinetcode |         84    13.89286    8.034591          1         28
     cowcode |         84    517.8452    69.14373        403        590
        year |         84    2002.357    6.825965       1990       2014
-------------+---------------------------------------------------------
presidential |         84    .3690476    .4854451          0          1
   partyname |          0
   formateur |         84    .3095238    .4650739          0          1
  portfolios |         84     7.02381    6.860005          1         26
governmen~os |         84    21.08333    6.637259          9         35
-------------+---------------------------------------------------------
 party_seats |         84    39.91667    56.69368          1        279
governmen~ts |         84    115.0952    86.61028         39        377
      region |         84           1           0          1          1

. gen portfolioshare = . ;
(84 missing values generated)

. replace portfolioshare = portfolios / government_portfolios ;
(84 real changes made)

. gen seatshare = . ;
(84 missing values generated)

. replace seatshare = party_seats / government_seats ;
(84 real changes made)

. encode partyname, generate(party);

. drop partyname;

. gen code = (region*100000) + (countrycode*1000) + cabinetcode ;

. *     ****************************************************************  *;
. *       Label variables                                                 *;
. *     ****************************************************************  *;
. label var countryname "country name";

. label var party_seats "number of legislative seats per party";

. label var party "party number or acronym";

. label var region "1=Africa, 2=Western Europe, 3=Latin America";

. label var cabinetcode "cabinet code";

. label var countrycode "country code";

. label var code "region, country code, cabinet code";

. label var cowcode "cow code";

. label var portfolios "number of portfolios per party";

. label var formateur "1 = formateur, 0 = otherwise";

. label var presidential "1 = presidential, 0 = parliamentary";

.  label var government_portfolios "number of portfolios in the government";

. label var government_seats "number of seats controlled by government";

. label var seatshare "party share of leg seats controlled by govt";

. label var portfolioshare "party share of govt portfolios";

. label var year "year in which government begins";

. sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 countryname |          0
 countrycode |         84    5.559524    2.552349          1          9
 cabinetcode |         84    13.89286    8.034591          1         28
     cowcode |         84    517.8452    69.14373        403        590
        year |         84    2002.357    6.825965       1990       2014
-------------+---------------------------------------------------------
presidential |         84    .3690476    .4854451          0          1
   formateur |         84    .3095238    .4650739          0          1
  portfolios |         84     7.02381    6.860005          1         26
governmen~os |         84    21.08333    6.637259          9         35
 party_seats |         84    39.91667    56.69368          1        279
-------------+---------------------------------------------------------
governmen~ts |         84    115.0952    86.61028         39        377
      region |         84           1           0          1          1
portfolios~e |         84    .3333333     .282168   .0344828   .9545454
   seatshare |         84    .3333333    .2628826   .0034843    .990099
       party |         84    25.91667    13.80083          1         48
-------------+---------------------------------------------------------
        code |         84    105573.4    2560.162     101001     109028

. desc;

Contains data from C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa_govt-party_obs.dta
  obs:            84                          
 vars:            16                          30 Mar 2017 12:12
 size:         4,368                          
------------------------------------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
------------------------------------------------------------------------------------------------------------------
countryname     str21   %21s                  country name
countrycode     byte    %8.0g                 country code
cabinetcode     byte    %8.0g                 cabinet code
cowcode         int     %8.0g                 cow code
year            int     %8.0g                 year in which government begins
presidential    byte    %8.0g                 1 = presidential, 0 = parliamentary
formateur       byte    %8.0g                 1 = formateur, 0 = otherwise
portfolios      byte    %8.0g                 number of portfolios per party
government_po~s byte    %8.0g                 number of portfolios in the government
party_seats     int     %8.0g                 number of legislative seats per party
government_se~s int     %8.0g                 number of seats controlled by government
region          byte    %8.0g                 1=Africa, 2=Western Europe, 3=Latin America
portfolioshare  float   %9.0g                 party share of govt portfolios
seatshare       float   %9.0g                 party share of leg seats controlled by govt
party           long    %9.0g      party      party number or acronym
code            float   %9.0g                 region, country code, cabinet code
------------------------------------------------------------------------------------------------------------------
Sorted by: 
     Note: Dataset has changed since last saved.

. *     ****************************************************************  *;
. *       Double-check total number of govt portfolios, seats             *;
. *     ****************************************************************  *;
. egen totalportfolio = total(portfolios), by(cabinetcode);

. correlate government_portfolios totalportfolio;
(obs=84)

             | gover~os totalp~o
-------------+------------------
governmen~os |   1.0000
totalportf~o |   1.0000   1.0000


. egen totalgovlegseats = total(party_seats), by(cabinetcode);

. correlate government_seats totalgovlegseats;
(obs=84)

             | gover~ts totalg~s
-------------+------------------
governmen~ts |   1.0000
totalgovle~s |   1.0000   1.0000


. *     ****************************************************************  *;
. *       Should be perfectly correlated, so can drop new variables.      *;
. *     ****************************************************************  *;
. drop totalportfolio totalgovlegseats ;

. save "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta", replace;
file C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta saved

. *     ****************************************************************  *;
. *       How large are Africa cabinets (partisan portfolios)?            *;
. *     ****************************************************************  *;
. collapse (mean) government_portfolios, by(cabinetcode);

. sum government_portfolios;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
government~s |         28    21.07143     6.76006          9         35

. log close;
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\ariottigolder.log
  log type:  text
 closed on:  30 Mar 2017, 14:06:15
------------------------------------------------------------------------------------------------------------------
